﻿using System;

namespace SelfMadeMillioniare.API.Helpers
{
    public static class DateHelper
    {
        public static double? DateTimeToMilliSeconds(DateTime? date)
        {
            if (!date.HasValue)
            {
                return null;
            }

            var utcTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
            
            return date.Value.Subtract(utcTime).TotalMilliseconds;
        }

        public static bool TryParseDate(string dateString, out DateTime date)
        {
            return DateTime.TryParse(dateString, out date);
        }

        public static int GetMinutesFromDays(int days)
        {
            return days*24*60;
        }
    }
}